﻿/*
 * Created by SharpDevelop.
 * User: IEscarro
 * Date: 9/3/2009
 * Time: 1:31 PM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
using Buaya.Model;

namespace Buaya.Gui
{
	/// <summary>
	/// Description of TaxSalaryRangeForm.
	/// </summary>
	public partial class TaxSalaryRangeForm : BaseForm
	{
		public TaxSalaryRangeForm() : this(new TaxSalaryRange())
		{
			
		}
		
		public TaxSalaryRangeForm(TaxSalaryRange t)
		{
			//
			// The InitializeComponent() call is required for Windows Forms designer support.
			//
			InitializeComponent();
			Model = t;
		}
		
		protected override void OnModelChanged(EventArgs e)
		{
			base.OnModelChanged(e);
			TaxSalaryRange t = Model as TaxSalaryRange;
			textBoxMonthlyStartSalary.Text = t.MonthlyStartSalary.ToString("0.00");
			textBoxMonthlyEndSalary.Text = t.MonthlyEndSalary.ToString("0.00");
			textBoxMonthlyBaseTax.Text = t.MonthlyBaseTax.ToString("0.00");
			textBoxSemiMonthlyStartSalary.Text = t.SemiMonthlyStartSalary.ToString("0.00");
			textBoxSemiMonthlyEndSalary.Text = t.SemiMonthlyEndSalary.ToString("0.00");
			textBoxSemiMonthlyBaseTax.Text = t.SemiMonthlyBaseTax.ToString("0.00");
			textBoxPercentOver.Text = t.PercentOver.ToString("0.00");
		}
		
		void ButtonOkClick(object sender, EventArgs e)
		{
			TaxSalaryRange t = Model as TaxSalaryRange;
			t.MonthlyStartSalary = Util.ConvertUtility.ToDouble(textBoxMonthlyStartSalary.Text);
			t.MonthlyEndSalary = Util.ConvertUtility.ToDouble(textBoxMonthlyEndSalary.Text);
			t.MonthlyBaseTax = Util.ConvertUtility.ToDouble(textBoxMonthlyBaseTax.Text);
			t.SemiMonthlyStartSalary = Util.ConvertUtility.ToDouble(textBoxSemiMonthlyStartSalary.Text);
			t.SemiMonthlyEndSalary = Util.ConvertUtility.ToDouble(textBoxSemiMonthlyEndSalary.Text);
			t.SemiMonthlyBaseTax = Util.ConvertUtility.ToDouble(textBoxSemiMonthlyBaseTax.Text);
			t.PercentOver = Util.ConvertUtility.ToDouble(textBoxPercentOver.Text);
			DialogResult = DialogResult.OK;
			Close();
		}
		
		void ButtonCancelClick(object sender, EventArgs e)
		{
			Close();
		}
	}
}
